package xyz.eden.cloud.common.web.result;


import xyz.eden.cloud.common.core.result.ResultSetEnum;
import xyz.eden.cloud.common.core.result.ResultSetTool;

/**
 * HttpResultSetUtils
 */
public class HttpResultSetTool extends ResultSetTool {

    /**
     * 构建 fail ResultSet
     *
     * @param code
     * @param msg
     * @param <T>
     * @return
     */
    public static <T> HttpResultSet<T> builderFail(int code, String msg) {
        return builderResultSet(code, msg, null);
    }
    public static <T> HttpResultSet<T> builderFail(String msg) {
        return builderResultSet(ResultSetEnum.ERROR_PARAM.getCode(), msg, null);
    }
    /**
     * 构建 success ResultSet
     *
     * @param data
     * @param <T>
     * @return
     */
    public static <T> HttpResultSet<T> builderSuccess(T data) {
        return builderResultSet(ResultSetEnum.SUCCESS.getCode(), ResultSetEnum.SUCCESS.getMsg(), data);
    }

    /**
     * 构建 ResultSet
     *
     * @param code
     * @param msg
     * @param data
     * @param <T>
     * @return
     */
    public static <T> HttpResultSet<T> builderResultSet(int code, String msg, T data) {
        return new HttpResultSet<>(code, msg, data);
    }
}
